class List:
    internalList = []
    #Common methods
    def isEmpty(self):
        return self.size() == 0

    def size(self):
        return len(self.internalList)

    def checkNotEmpty(self):
        if self.isEmpty():
            raise Exception("Empty List!  There are no elements to wok with.")

    def __iter__(self):
        return self.internalList.__iter__()

    def __repr__(self):
        return "a List with[" + ", ".join(map(str, self.internalList)) + "]"

    #End of Common methods

    def __getitem__(self, index):
        return self.internalList[index]

    def add(self, element):
        self.internalList.append(element)

    def insertAtIndex(self, index, element):
        return self.internalList.insert(index, element)

    def insertAfter(self, afterWho, element):
        return self.internalList.insert(self.internalList.index(afterWho) + 1, element)

    def insertBefore(self, beforeWho, element):
        return self.internalList.insert(self.internalList.index(beforeWho), element)

    def remove(self, element):
        self.internalList.remove(element)

    def removeAtIndex(self, index):
        self.internalList.pop(index)

    def removeFirst(self):
        self.internalList.pop(0)

    def removeLast(self):
        self.internalList.pop()

def createList():
    return List()

def addToList(aList, element):
    aList.add(element)

def insertAtIndexToList(aList, index, element):
    aList.insertAtIndex(index, element)

def insertAfter(aList, afterWho, element):
    aList.insertAfter(afterWho, element)

def insertBefore(aList, beforeWho, element):
    aList.insertBefore(beforeWho, element)

def removeFromList(aList, element):
    return aList.remove(element)

def removeAtIndexFromList(aList, index):
    return aList.removeAtIndex(index)

def removeFirstFromList(aList):
    return aList.removeFirst()

def removeLastFromList(aList):
    return aList.removeLast()

def isEmptyList(aList):
    return aList.isEmpty()

def sizeOfList(aList):
    return aList.size()
